package com.rrd.dw.mr.gzip.kafka;

import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.blzcredit.*;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Classname BingJianDayPupilParse
 * @Description 避雷针-图赫名单
 * @Date 2021/6/9 21:05
 * @Created by lzw
 */
public class BiLeiHitListParse extends ParseBase {
    Text key = new Text();
    Text value = new Text();

    @Override
    public boolean parseJob(Mapper.Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        BlzCreditHitListRecord obj = (BlzCreditHitListRecord) model;
        StringBuilder sb = getBaseInfo(obj, successful);

        BlzCreditHitListData info = obj.getData();

        sb.append(info.getReqId()).append(CRT001);
        sb.append(info.getTrxId()).append(CRT001);
        sb.append(info.getCode()).append(CRT001);
        sb.append(info.getMsg()).append(CRT001);
        sb.append(info.getDetail()).append(CRT001);
        sb.append(info.getFeeFlag()).append(CRT001);

        BlzCreditHitListScore blzCreditHitListScore = info.getData();

        sb.append(blzCreditHitListScore.getResult()).append(CRT001);
        sb.append(blzCreditHitListScore.getResultMsg()).append(CRT001);

        key.set(getKey());
        value.set(sb.toString().replace("\n", " ").replace("\r", " "));
        context.write(key, value);


        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_bileizhen_hitlist_inc";
    }

    @Override
    public String getType() {
        return RecordType.BLZ_CREDIT_HITLIST_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "避雷针-图赫名单";
    }
}
